﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:system="clr-namespace:System;assembly=mscorlib"   
     >

    <ControlTemplate x:Key="ComboBoxToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="HoverOn">
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="rectangleOver" Storyboard.TargetProperty="Opacity" To="1.0" />
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="1.0" />
            </Storyboard>
            <Storyboard x:Key="HoverOff">
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="rectangleOver" Storyboard.TargetProperty="Opacity" To="0" />
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="0" />
            </Storyboard>
            <Storyboard x:Key="PressedOn">
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="rectanglePress" Storyboard.TargetProperty="Opacity" To="1.0" />
            </Storyboard>
            <Storyboard x:Key="PressedOff">
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="rectanglePress" Storyboard.TargetProperty="Opacity" To="0" />
            </Storyboard>
            <Storyboard x:Key="CheckedOn">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="BackgroundChecked" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="rectanglePress" Storyboard.TargetProperty="Opacity" To="1.0" />
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerShadow" Storyboard.TargetProperty="Opacity" To="1.0" />
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerShadow2" Storyboard.TargetProperty="Opacity" To="1.0" />
            </Storyboard>
            <Storyboard x:Key="CheckedOff">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="BackgroundChecked" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="rectanglePress" Storyboard.TargetProperty="Opacity" To="0" />
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientInnerShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientInnerShadow2" Storyboard.TargetProperty="Opacity" To="0.0" />
            </Storyboard>
        </ControlTemplate.Resources>
        <Grid x:Name="grid">
            <Rectangle x:Name="Background" Fill="{DynamicResource BackgroundBrush_ComboBox}" Stroke="{DynamicResource BorderBrush_ComboBox}" IsHitTestVisible="false" />
            <Rectangle x:Name="BackgroundChecked" Fill="{DynamicResource BackgroundBrush_ComboBox}" Stroke="{DynamicResource BorderBrush_ComboBox}" IsHitTestVisible="false" Opacity="0" >

            </Rectangle>
            <Rectangle x:Name="rectangleOver" Width="15" HorizontalAlignment="Right" Stroke="{DynamicResource MouseOverBorderBrush_ComboItem}" Opacity="0" Fill="{DynamicResource MouseOverBrush_ComboItem}"/>
            <Border x:Name="BackgroundGradientInnerOver" BorderThickness="1" Width="13" IsHitTestVisible="false" HorizontalAlignment="Right" Margin="1" BorderBrush="{DynamicResource MouseOverInnerBorderBrush_ComboItem}" Opacity="0" Background="Transparent"/>
            <Rectangle x:Name="rectanglePress" Width="15" StrokeThickness="1" Stroke="{DynamicResource PressedBorderBrush_ComboItem}" HorizontalAlignment="Right" Opacity="0" Fill="{DynamicResource SelectedBrush_ComboItem}"/>
            <Border x:Name="BackgroundGradientInnerShadow" BorderThickness="1" Width="13" IsHitTestVisible="false" HorizontalAlignment="Right" Margin="1" BorderBrush="{DynamicResource PressedShadowBorderBrush_ComboItem}" Opacity="0" Background="Transparent"/>
            <Border x:Name="BackgroundGradientInnerShadow2" BorderThickness="1" Width="11" IsHitTestVisible="false" HorizontalAlignment="Right" Margin="2" BorderBrush="{DynamicResource PressedInnerShadowBorderBrush_ComboItem}" Opacity="0" Background="Transparent"/>
            <Rectangle x:Name="DisabledVisualElement" Margin="1" Fill="{DynamicResource DisabledBackgroundBrush_ComboBox}" IsHitTestVisible="false" Visibility="Collapsed" />
            <Path x:Name="BtnArrow" Margin="0,0,4,0" Width="6" Fill="{DynamicResource GlyphBrush_ComboBox}" Stretch="Uniform" HorizontalAlignment="Right" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="True">
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource PressedOff}" x:Name="PressedOff_BeginStoryboard" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource PressedOn}" x:Name="PressedOn_BeginStoryboard" />
                </Trigger.EnterActions>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource HoverOn}" x:Name="HoverOn_BeginStoryboard" />
                </Trigger.EnterActions>

            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource CheckedOff}" x:Name="CheckedOff_BeginStoryboard" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard 
                        Storyboard="{StaticResource CheckedOn}" x:Name="CheckedOn_BeginStoryboard" />
                </Trigger.EnterActions>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush_Button}" />
                <Setter Property="Visibility" TargetName="DisabledVisualElement" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ComboBoxTextBoxStyle" TargetType="{x:Type TextBox}">
        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
    </ControlTemplate>

    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush_Button}" />
        <Setter Property="FontFamily" Value="SimSun" />
        <Setter Property="FontSize" Value="13" />
        <Setter Property="Padding" Value="6,2,25,2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="FocusedOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="FocusedOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <ToggleButton Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" Style="{x:Null}" />
                        <ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxToggleButtonStyle}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
                        <ContentPresenter HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False" />

                        <TextBox Visibility="Hidden" Template="{DynamicResource ComboBoxTextBoxStyle}" HorizontalAlignment="Left" Margin="3,3,23,3" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Focusable="True" Background="Transparent"  />
                        <Rectangle x:Name="DisabledVisualElement" Fill="{DynamicResource DisabledBackgroundBrush_ComboBox}" Stroke="{DynamicResource DisabledBorderBrush_ComboBox}" RadiusX="0" RadiusY="0" IsHitTestVisible="false" Opacity="0" />
                        <Rectangle x:Name="FocusVisualElement" Margin="-1" Stroke="{DynamicResource FocusBrush_ComboBox}" StrokeThickness="1" IsHitTestVisible="false" Opacity="0" />
                        <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide" Margin="0,0,0,0">
                            <Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
                                <Border x:Name="DropDownBorder" Margin="0,0,0,0" BorderBrush="{DynamicResource BorderBrush_ComboBox}" BorderThickness="1" CornerRadius="0,0,0,0" Background="{DynamicResource BackgroundBrush_ComboBoxDropDown}">
                                    <ScrollViewer  Margin="1" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Border>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard" />
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="HasItems" Value="false">
                            <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="Silver" />
                            <Setter Property="Opacity" TargetName="DisabledVisualElement" Value="1" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                        <Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
                            <Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder" />
                            <Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder" />
                        </Trigger>
                        <Trigger Property="IsEditable" Value="true">
                            <Setter Property="IsTabStop" Value="false" />
                            <Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox" />
                            <Setter Property="Visibility" Value="Hidden" TargetName="ContentSite" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style  TargetType="{x:Type ComboBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush_Button}" />
        <Setter Property="FontFamily" Value="SimSun" />
        <Setter Property="FontSize" Value="13" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HighlightOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="1.0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="1.0" />
                        </Storyboard>
                        <Storyboard x:Key="HighlightOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="0.0" />
                        </Storyboard>
                        <Storyboard x:Key="SelectedOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="1.0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelectedShadow" Storyboard.TargetProperty="Opacity" To="1.0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelectedInnerShadow" Storyboard.TargetProperty="Opacity" To="1.0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="1.0" />
                        </Storyboard>
                        <Storyboard x:Key="SelectedOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelected" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedInnerShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="0.0" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid SnapsToDevicePixels="true">
                        <Rectangle x:Name="BackgroundGradientSelected" Stroke="{DynamicResource PressedBorderBrush_ListItem}" Fill="{DynamicResource SelectedBrush_ListItem}" StrokeThickness="1" RadiusX="3" RadiusY="3" Opacity="0"/>
                        <Rectangle Margin="1" x:Name="BackgroundGradientSelectedShadow" Stroke="{DynamicResource PressedShadowBorderBrush_ListItem}" Fill="Transparent"  StrokeThickness="1" RadiusX="3" RadiusY="3" Opacity="0"/>
                        <Rectangle Margin="2" x:Name="BackgroundGradientSelectedInnerShadow" Stroke="{DynamicResource PressedInnerShadowBorderBrush_ListItem}" Fill="Transparent" StrokeThickness="1" RadiusX="3" RadiusY="3" Opacity="0"/>
                        <Rectangle x:Name="BackgroundGradientOver" RadiusX="3" RadiusY="3" Stroke="{DynamicResource MouseOverBorderBrush_ListItem}" Opacity="0" Fill="{DynamicResource MouseOverBrush_ListItem}"/>
                        <Rectangle x:Name="BackgroundGradientInnerOver" Margin="1" RadiusX="3" RadiusY="3" Stroke="{DynamicResource MouseOverInnerBorderBrush_ListItem}" Opacity="0" Fill="Transparent"/>
                        <Rectangle x:Name="BackgroundGradientSelectedDisabled" RadiusX="3" RadiusY="3" Opacity="0" Stroke="{DynamicResource SelectedBorderBrush_ListItem}"/>
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Selector.IsSelected" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOff}" x:Name="SelectedOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}" x:Name="SelectedOn_BeginStoryboard1" />
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HighlightOff}" x:Name="HighlightOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HighlightOn}" x:Name="HighlightOn_BeginStoryboard"/>
                            </Trigger.EnterActions>
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush_Button}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
